// main.js
import { createSSRApp } from 'vue'
// 引入 Pinia
import { createPinia } from 'pinia'
// import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import { createPersistedState } from 'pinia-plugin-persistedstate'
import App from './App'
import '@/utils/utils'
export function createApp() {
  const app = createSSRApp(App)
  // 实例化Pinia
  const pinia = createPinia()
     // Pinia 持久化插件
  // 自定义pinia
  pinia.use(createPersistedState({
    key: (id) => `__persisted__${id}`,
    storage:{
      getItem: (key) => {
        return uni.getStorageSync(key)
      },
      setItem: (key, value) => {
        uni.setStorageSync(key, value)
      },
    }
  }))
  app.use(pinia)

  return { app }
}